<!DOCTYPE html>
<html>
<head>
    <title>Graph Editor</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">var ctx = ""; CONTEXT_PATH = "../..";</script>
    <link rel="stylesheet" type="text/css" href="styles/grapheditor.css">

    <script type="text/javascript">
        // Public global variables
        var MAX_REQUEST_SIZE = 10485760;
        var MAX_WIDTH = 6000;
        var MAX_HEIGHT = 6000;

        // URLs for save and export
        var EXPORT_URL = '/export';
        var SAVE_URL = '/save';
        var OPEN_URL = '/open';
        var RESOURCES_PATH = 'resources';
        var RESOURCE_BASE = RESOURCES_PATH + '/grapheditor';
        var STENCIL_PATH = 'stencils';
        var IMAGE_PATH = 'images';
        var STYLE_PATH = 'styles';
        var CONFIG_PATH = 'config';
        var CSS_PATH = 'styles';
        var OPEN_FORM = 'open.html';

        // Specifies connection mode for touch devices (at least one should be true)
        var tapAndHoldStartsConnection = true;
        var showConnectorImg = true;

        // Parses URL parameters. Supported parameters are:
        // - lang=xy: Specifies the language of the user interface.
        // - touch=1: Enables a touch-style user interface.
        // - storage=local: Enables HTML5 local storage.
        var urlParams = (function (url) {
            var result = new Object();
            var idx = url.lastIndexOf('?');

            if (idx > 0) {
                var params = url.substring(idx + 1).split('&');

                for (var i = 0; i < params.length; i++) {
                    idx = params[i].indexOf('=');

                    if (idx > 0) {
                        result[params[i].substring(0, idx)] = params[i].substring(idx + 1);
                    }
                }
            }

            return result;
        })(window.location.href);

        mxLoadResources = false;
        mxBasePath = '../WorkflowDesigner';
        mxLanguage = urlParams['lang'];
        mxLanguages = ['zh'];
    </script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="mxGraph/mxClient.js"></script>
    <script type="text/javascript" src="js/DomHelper.js"></script>
    <script type="text/javascript" src="js/Editor.js"></script>
    <script type="text/javascript" src="js/Shapes.js"></script>
    <script type="text/javascript" src="js/EditorUi.js"></script>
    <script type="text/javascript" src="js/Graph.js"></script>
    <script type="text/javascript" src="js/Actions.js"></script>
    <script type="text/javascript" src="js/Menus.js"></script>
    <script type="text/javascript" src="js/Sidebar.js"></script>
    <script type="text/javascript" src="js/Toolbar.js"></script>
    <script type="text/javascript" src="js/Dialogs.js"></script>
    <script type="text/javascript" src="js/Nodes.js"></script>
    <script type="text/javascript" src="js/Translation.js"></script>
    <script type="text/javascript" src="js/WfModel.js"></script>
    <script type="text/javascript" src="js/Validation.js"></script>
    <script type="text/javascript" src="jscolor/jscolor.js"></script>
    <script type="text/javascript" src="FormBuilder/js/Math.uuid.js"></script>
    <script type="text/javascript" src="js/Gjspflow.js"></script>
</head>
<body class="geEditor" id="portal" oncontextmenu="return false">
<script type="text/javascript">

    (function () {
        var editorUiInit = EditorUi.prototype.init;

        EditorUi.prototype.init = function () {
            editorUiInit.apply(this, arguments);
            this.actions.get('export').setEnabled(false);
        };
    })();
    console.log('-----000', EditorUi);
    var EDITOR = new EditorUi(new Editor());
    console.log('-----0001', EDITOR);
    function loadWorkflowXml(xml) {
        var doc = DomHelper.parseXml(xml);
        if (doc.documentElement.nodeName != 'mxGraphModel' &&
            doc.documentElement.nodeName != 'WorkflowProcess') {
            alert('XML解析失败！');
            return;
        }
        EDITOR.editor.setWorkflowXml(doc.documentElement);
    }

    function openSettingPanel() {
        EDITOR.actions.get('settings').funct();
    }

    function initNewProcess(config) {
        var workflow = EDITOR.editor.graph.getWorkflow();
        workflow.setAttribute('Category', config.categoryId);
        workflow.setAttribute('Description', config.description);
        workflow.setAttribute('Author', '');
        EDITOR.editor.createFreeflow(config);
    }

    // Placeholder for parent.Message.send("wfdesigner", "loadComplete"); functionality
    window.onload = function() {
        console.log("Page load complete111.", window);
        // var ui = this.editorUi;
        // ui.showDialog(new PrintDialog(ui).container, 300, 200, true, true);
        // window.Dialog("wfdesigner");
    };

</script>
</body>
</html>